
import router from '../router'

export function open(url, params = {}) {
  if (process.env.NODE_ENV == 'production') {
    // 处理参数，拼接URL
    const temp = [];
    for (const key of Object.keys(params)) {
      temp.push(`${key}=${params[key]}`);
    }
    let baseUrl = (process.env.BASE_URL || '/').split('');
    if (baseUrl[baseUrl.length - 1] == '/') baseUrl.pop();
    baseUrl = baseUrl.join('');
    // 调起APP的能力，打开新窗口
    // qm.jump.openNewBrowser({
    //   url: window.location.origin + baseUrl + url + (temp.length > 0 ? "?" + temp.join('&') : ""),
    //   onSuccess: function(){},
    //   onError: function(){}
    // } );
    bmapi.jump.openURLInNewWindow({
      url: window.location.origin + baseUrl + url + (temp.length > 0 ? "?" + temp.join('&') : ""),
      onSuccess: function () { },
      onError: function () { }
    });


    // bmapi.jump.openURLInNewWindow({url:document.getElementById('url').value,zwt:{'name':1},onSucess:commonSuccessHandler(),onError:commonErrorHandler()})
  } else {
    router.push({ path: url, query: params });
    // this.$router.push( { path: url, query: params } );
  }
};